/*     */ package com.zimbra.cs.account.ldap;
/*     */ 
/*     */ import com.zimbra.common.account.Key.DomainBy;
/*     */ import com.zimbra.common.localconfig.KnownKey;
/*     */ import com.zimbra.common.localconfig.LC;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.cs.account.Account;
/*     */ import com.zimbra.cs.account.AlwaysOnCluster;
/*     */ import com.zimbra.cs.account.Domain;
/*     */ import com.zimbra.cs.account.Group;
/*     */ import com.zimbra.cs.account.NamedEntry;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.account.Server;
/*     */ import com.zimbra.cs.account.ShareLocator;
/*     */ import com.zimbra.cs.account.UCService;
/*     */ import com.zimbra.cs.account.XMPPComponent;
/*     */ import com.zimbra.cs.account.cache.AccountCache;
/*     */ import com.zimbra.cs.account.cache.DomainCache;
/*     */ import com.zimbra.cs.account.cache.DomainCache.GetFromDomainCacheOption;
/*     */ import com.zimbra.cs.account.cache.IAccountCache;
/*     */ import com.zimbra.cs.account.cache.IDomainCache;
/*     */ import com.zimbra.cs.account.cache.IMimeTypeCache;
/*     */ import com.zimbra.cs.account.cache.INamedEntryCache;
/*     */ import com.zimbra.cs.account.cache.NamedEntryCache;
/*     */ import com.zimbra.cs.account.ldap.entry.LdapCos;
/*     */ import com.zimbra.cs.account.ldap.entry.LdapZimlet;
/*     */ import com.zimbra.cs.mime.MimeTypeInfo;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Collections;
/*     */ import java.util.List;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ abstract class LdapCache
/*     */ {
/*     */   abstract IAccountCache accountCache();
/*     */   
/*     */   abstract INamedEntryCache<LdapCos> cosCache();
/*     */   
/*     */   abstract INamedEntryCache<ShareLocator> shareLocatorCache();
/*     */   
/*     */   abstract IDomainCache domainCache();
/*     */   
/*     */   abstract IMimeTypeCache mimeTypeCache();
/*     */   
/*     */   abstract INamedEntryCache<Server> serverCache();
/*     */   
/*     */   abstract INamedEntryCache<UCService> ucServiceCache();
/*     */   
/*     */   abstract INamedEntryCache<LdapZimlet> zimletCache();
/*     */   
/*     */   abstract INamedEntryCache<Group> groupCache();
/*     */   
/*     */   abstract INamedEntryCache<XMPPComponent> xmppComponentCache();
/*     */   
/*     */   abstract INamedEntryCache<AlwaysOnCluster> alwaysOnClusterCache();
/*     */   
/*     */   static class LRUMapCache
/*     */     extends LdapCache
/*     */   {
/*  72 */     private final IAccountCache accountCache = new AccountCache(LC.ldap_cache_account_maxsize.intValue(), LC.ldap_cache_account_maxage.intValue() * 60000L);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*  77 */     private final INamedEntryCache<LdapCos> cosCache = new NamedEntryCache(LC.ldap_cache_cos_maxsize.intValue(), LC.ldap_cache_cos_maxage.intValue() * 60000L);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*  82 */     private final INamedEntryCache<ShareLocator> shareLocatorCache = new NamedEntryCache(LC.ldap_cache_share_locator_maxsize.intValue(), LC.ldap_cache_share_locator_maxage.intValue() * 60000L);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*  87 */     private final IDomainCache domainCache = new DomainCache(LC.ldap_cache_domain_maxsize.intValue(), LC.ldap_cache_domain_maxage.intValue() * 60000L, LC.ldap_cache_external_domain_maxsize.intValue(), LC.ldap_cache_external_domain_maxage.intValue() * 60000L);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*  94 */     private final IMimeTypeCache mimeTypeCache = new LdapMimeTypeCache();
/*     */     
/*  96 */     private final INamedEntryCache<Server> serverCache = new NamedEntryCache(LC.ldap_cache_server_maxsize.intValue(), LC.ldap_cache_server_maxage.intValue() * 60000L);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/* 101 */     private final INamedEntryCache<UCService> ucServiceCache = new NamedEntryCache(LC.ldap_cache_ucservice_maxsize.intValue(), LC.ldap_cache_ucservice_maxage.intValue() * 60000L);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/* 106 */     private final INamedEntryCache<LdapZimlet> zimletCache = new NamedEntryCache(LC.ldap_cache_zimlet_maxsize.intValue(), LC.ldap_cache_zimlet_maxage.intValue() * 60000L);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 112 */     private final INamedEntryCache<Group> groupCache = new NamedEntryCache(LC.ldap_cache_group_maxsize.intValue(), LC.ldap_cache_group_maxage.intValue() * 60000L);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/* 117 */     private final INamedEntryCache<XMPPComponent> xmppComponentCache = new NamedEntryCache(LC.ldap_cache_xmppcomponent_maxsize.intValue(), LC.ldap_cache_xmppcomponent_maxage.intValue() * 60000L);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/* 122 */     private final INamedEntryCache<AlwaysOnCluster> alwaysOnClusterCache = new NamedEntryCache(LC.ldap_cache_alwaysoncluster_maxsize.intValue(), LC.ldap_cache_alwaysoncluster_maxage.intValue() * 60000L);
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */     IAccountCache accountCache()
/*     */     {
/* 129 */       return this.accountCache;
/*     */     }
/*     */     
/*     */     INamedEntryCache<LdapCos> cosCache()
/*     */     {
/* 134 */       return this.cosCache;
/*     */     }
/*     */     
/*     */     IDomainCache domainCache()
/*     */     {
/* 139 */       return this.domainCache;
/*     */     }
/*     */     
/*     */     INamedEntryCache<Group> groupCache()
/*     */     {
/* 144 */       return this.groupCache;
/*     */     }
/*     */     
/*     */     IMimeTypeCache mimeTypeCache()
/*     */     {
/* 149 */       return this.mimeTypeCache;
/*     */     }
/*     */     
/*     */     INamedEntryCache<Server> serverCache()
/*     */     {
/* 154 */       return this.serverCache;
/*     */     }
/*     */     
/*     */     INamedEntryCache<UCService> ucServiceCache()
/*     */     {
/* 159 */       return this.ucServiceCache;
/*     */     }
/*     */     
/*     */     INamedEntryCache<ShareLocator> shareLocatorCache()
/*     */     {
/* 164 */       return this.shareLocatorCache;
/*     */     }
/*     */     
/*     */     INamedEntryCache<XMPPComponent> xmppComponentCache()
/*     */     {
/* 169 */       return this.xmppComponentCache;
/*     */     }
/*     */     
/*     */     INamedEntryCache<LdapZimlet> zimletCache()
/*     */     {
/* 174 */       return this.zimletCache;
/*     */     }
/*     */     
/*     */     INamedEntryCache<AlwaysOnCluster> alwaysOnClusterCache()
/*     */     {
/* 179 */       return this.alwaysOnClusterCache;
/*     */     }
/*     */   }
/*     */   
/*     */   static class NoopCache extends LdapCache {
/*     */     private final IAccountCache accountCache;
/*     */     private final INamedEntryCache<LdapCos> cosCache;
/*     */     private final INamedEntryCache<ShareLocator> shareLocatorCache;
/*     */     private final IDomainCache domainCache;
/*     */     private final IMimeTypeCache mimeTypeCache;
/*     */     
/*     */     NoopCache() {
/* 191 */       this.accountCache = new NoopAccountCache();
/* 192 */       this.cosCache = new NoopNamedEntryCache();
/* 193 */       this.shareLocatorCache = new NoopNamedEntryCache();
/* 194 */       this.domainCache = new NoopDomainCache();
/* 195 */       this.mimeTypeCache = new NoopMimeTypeCache();
/* 196 */       this.serverCache = new NoopNamedEntryCache();
/* 197 */       this.ucServiceCache = new NoopNamedEntryCache();
/* 198 */       this.zimletCache = new NoopNamedEntryCache();
/* 199 */       this.groupCache = new NoopNamedEntryCache();
/* 200 */       this.xmppComponentCache = new NoopNamedEntryCache();
/* 201 */       this.alwaysOnClusterCache = new NoopNamedEntryCache();
/*     */     }
/*     */     
/*     */ 
/*     */     static class NoopAccountCache
/*     */       implements IAccountCache
/*     */     {
/*     */       public void clear() {}
/*     */       
/*     */       public void remove(Account entry) {}
/*     */       
/*     */       public void put(Account entry) {}
/*     */       
/*     */       public void replace(Account entry) {}
/*     */       
/*     */       public Account getById(String key)
/*     */       {
/* 218 */         return null;
/*     */       }
/*     */       
/* 221 */       public Account getByName(String key) { return null; }
/*     */       
/*     */       public Account getByForeignPrincipal(String key) {
/* 224 */         return null;
/*     */       }
/*     */       
/* 227 */       public int getSize() { return 0; }
/*     */       
/*     */       public double getHitRate() {
/* 230 */         return 0.0D;
/*     */       }
/*     */     }
/*     */     
/*     */     static class NoopDomainCache implements IDomainCache
/*     */     {
/*     */       public void clear() {}
/*     */       
/*     */       public Domain getByForeignName(String key, DomainCache.GetFromDomainCacheOption option) {
/* 239 */         return null;
/*     */       }
/*     */       
/* 242 */       public Domain getById(String key, DomainCache.GetFromDomainCacheOption option) { return null; }
/*     */       
/*     */       public Domain getByKrb5Realm(String key, DomainCache.GetFromDomainCacheOption option) {
/* 245 */         return null;
/*     */       }
/*     */       
/* 248 */       public Domain getByName(String key, DomainCache.GetFromDomainCacheOption option) { return null; }
/*     */       
/*     */       public Domain getByVirtualHostname(String key, DomainCache.GetFromDomainCacheOption option) {
/* 251 */         return null;
/*     */       }
/*     */       
/*     */ 
/*     */       public void put(Key.DomainBy domainBy, String key, Domain entry) {}
/*     */       
/*     */ 
/*     */       public void remove(Domain entry) {}
/*     */       
/*     */       public void removeFromNegativeCache(Key.DomainBy domainBy, String key) {}
/*     */       
/*     */       public void replace(Domain entry) {}
/*     */       
/*     */       public double getHitRate()
/*     */       {
/* 266 */         return 0.0D;
/*     */       }
/*     */       
/* 269 */       public int getSize() { return 0; }
/*     */     }
/*     */     
/*     */     static class NoopNamedEntryCache<E extends NamedEntry>
/*     */       implements INamedEntryCache<E>
/*     */     {
/*     */       public void clear() {}
/*     */       
/*     */       public E getById(String key)
/*     */       {
/* 279 */         return null;
/*     */       }
/*     */       
/* 282 */       public E getByName(String key) { return null; }
/*     */       
/*     */       public double getHitRate() {
/* 285 */         return 0.0D;
/*     */       }
/*     */       
/* 288 */       public int getSize() { return 0; }
/*     */       
/*     */       public void put(E entry) {}
/*     */       
/*     */       public void put(List<E> entries, boolean clear) {}
/*     */       
/*     */       public void remove(String name, String id) {}
/*     */       
/*     */       public void remove(E entry) {}
/*     */       
/*     */       public void replace(E entry) {}
/*     */     }
/*     */     
/*     */     private final INamedEntryCache<Server> serverCache;
/*     */     private final INamedEntryCache<UCService> ucServiceCache;
/*     */     private final INamedEntryCache<LdapZimlet> zimletCache;
/*     */     private final INamedEntryCache<Group> groupCache;
/*     */     private final INamedEntryCache<XMPPComponent> xmppComponentCache;
/*     */     private final INamedEntryCache<AlwaysOnCluster> alwaysOnClusterCache;
/*     */     static class NoopMimeTypeCache implements IMimeTypeCache {
/* 308 */       private final List<MimeTypeInfo> mimeTypes = Collections.unmodifiableList(new ArrayList());
/*     */       
/*     */       public void flushCache(Provisioning prov)
/*     */         throws ServiceException
/*     */       {}
/*     */       
/*     */       public List<MimeTypeInfo> getAllMimeTypes(Provisioning prov)
/*     */         throws ServiceException
/*     */       {
/* 317 */         return this.mimeTypes;
/*     */       }
/*     */       
/*     */       public List<MimeTypeInfo> getMimeTypes(Provisioning prov, String mimeType)
/*     */         throws ServiceException
/*     */       {
/* 323 */         return this.mimeTypes;
/*     */       }
/*     */     }
/*     */     
/*     */ 
/*     */     IAccountCache accountCache()
/*     */     {
/* 330 */       return this.accountCache;
/*     */     }
/*     */     
/*     */     INamedEntryCache<LdapCos> cosCache()
/*     */     {
/* 335 */       return this.cosCache;
/*     */     }
/*     */     
/*     */     IDomainCache domainCache()
/*     */     {
/* 340 */       return this.domainCache;
/*     */     }
/*     */     
/*     */     INamedEntryCache<Group> groupCache()
/*     */     {
/* 345 */       return this.groupCache;
/*     */     }
/*     */     
/*     */     IMimeTypeCache mimeTypeCache()
/*     */     {
/* 350 */       return this.mimeTypeCache;
/*     */     }
/*     */     
/*     */     INamedEntryCache<Server> serverCache()
/*     */     {
/* 355 */       return this.serverCache;
/*     */     }
/*     */     
/*     */     INamedEntryCache<UCService> ucServiceCache()
/*     */     {
/* 360 */       return this.ucServiceCache;
/*     */     }
/*     */     
/*     */     INamedEntryCache<ShareLocator> shareLocatorCache()
/*     */     {
/* 365 */       return this.shareLocatorCache;
/*     */     }
/*     */     
/*     */     INamedEntryCache<XMPPComponent> xmppComponentCache()
/*     */     {
/* 370 */       return this.xmppComponentCache;
/*     */     }
/*     */     
/*     */     INamedEntryCache<LdapZimlet> zimletCache()
/*     */     {
/* 375 */       return this.zimletCache;
/*     */     }
/*     */     
/*     */     INamedEntryCache<AlwaysOnCluster> alwaysOnClusterCache()
/*     */     {
/* 380 */       return this.alwaysOnClusterCache;
/*     */     }
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/ldap/LdapCache.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */